package mortal.component.window
{
	import com.mui.core.*;
	import com.mui.display.*;
	import flash.display.*;
	import mortal.component.gconst.*;
	
	public class BaseWindow extends Window
	{
		protected var _windowCenter:ScaleBitmap;
		protected var _patternLeft:Bitmap;
		protected var _patternRight:Bitmap;
		protected var paddingTop:int = 7;
		protected var paddingBottom:int = 7;
		protected var paddingLeft:int = 13;
		protected var paddingRight:int = 13;
		
		public function BaseWindow()
		{
		}
		
		override protected function createChildren() : void
		{
			_windowBg = ResouceConst.getScaleBitmap("WindowBg");
			$addChildAt(_windowBg, 0);
			this.setWindowCenter();
			if (this._windowCenter)
			{
				$addChild(this._windowCenter);
			}
			super.createChildren();
			this._patternLeft = GlobalClass.getBitmap("WindowPattern");
			$addChild(this._patternLeft);
			this._patternRight = GlobalClass.getBitmap("WindowPattern");
			this._patternRight.scaleX = -1;
			$addChild(this._patternRight);
			
		}
		
		protected function setWindowCenter() : void
		{
			this._windowCenter = ResouceConst.getScaleBitmap("WindowCenterA");
			
		}
		
		override protected function updateSize() : void
		{
			super.updateSize();
			this._patternLeft.x = 6;
			this._patternLeft.y = this.height - this._patternLeft.height;
			this._patternRight.x = this.width - 6;
			this._patternRight.y = this.height - this._patternRight.height;
			if (_windowBg)
			{
				_windowBg.setSize(this.width, this.height);
				_windowBg.x = 0;
				_windowBg.y = 0;
			}
			this.updateWindowCenterSize();
			
		}
		
		protected function set padding(param1:int) : void
		{
			this.paddingTop = param1;
			this.paddingBottom = param1;
			this.paddingLeft = param1;
			this.paddingRight = param1;
			
		}
		
		protected function updateWindowCenterSize() : void
		{
			var _loc_1:Number = NaN;
			var _loc_2:Number = NaN;
			if (this._windowCenter)
			{
				_loc_1 = this.width - this.paddingLeft - this.paddingRight;
				_loc_2 = this.height - this.paddingTop - this.paddingBottom - _titleHeight;
				this._windowCenter.setSize(_loc_1, _loc_2);
				this._windowCenter.x = this.paddingLeft;
				this._windowCenter.y = _titleHeight + this.paddingTop;
			}
			
		}
		
		override protected function updateDisplayList() : void
		{
			super.updateDisplayList();
			
		}
		
		override public function dispose() : void
		{
			_windowBg = null;
			this._windowCenter = null;
			_title = null;
			this._patternLeft = null;
			this._patternRight = null;
			super.dispose();
			
		}
		
	}
}
